package com.xja.controller;/**
 * @className: FoodController
 * @description: TODO 类描述
 * @author: wkx
 * @date: 2022/4/14
 **/

import com.xja.pojo.Food;
import com.xja.pojo.Type;
import com.xja.service.FoodService;
import com.xja.service.TypeService;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @ClassName : FoodController  //类名

 * @Author : Lenovo //作者
 * @Date: 2022/4/14  12:13
 */
@Controller
@RequestMapping("food")
public class FoodController {
    private Logger logger = LoggerFactory.getLogger(FoodController.class);
    @Reference(url = "dubbo://localhost:20882")
    FoodService foodService;
    @Reference(url = "dubbo://localhost:20883")
    TypeService typeService;

    @RequestMapping("getFood")
    public String getFood(Model model, @RequestParam(value = "page",defaultValue = "1") Integer page, Food food){
        logger.info("获取食品菜单");
        List<Food> foodList = foodService.getFoodList(food, page);
        List<Type> typeList = typeService.getTypeList();
        model.addAttribute("foodList",foodList);
        model.addAttribute("typeList",typeList);
        return "index";
    }
}
